/* dgnbbs_cored.c : bbs core daemon
 * CopyRight (C) 2008  dgnbbs
 * drangon_zhou@21cn.com
 * 2008-10
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "bs_system.h"

#include <stdio.h>
#include <unistd.h>
#include <errno.h>

int main( int argc, char * argv[] )
{
	os_cfg_t cfg;
	if( chdir( "/home/bbs" ) < 0 ) {
		fprintf( stderr, "chdir [%s] failed, errno %d\n", "/home/bbs", errno );
		exit( -1 );
	}
	if( daemon( 1, 0 ) < 0 ) {
		fprintf( stderr, "daemon failed, errno %d\n", errno );
		exit( -1 );
	}

	cfg = os_cfg_open( "./etc/dgnbbs.conf" );
	bs_system_open_init( cfg );

	while( 1 ) {
		sleep( 2 );
	}

	bs_system_close();
	os_cfg_close( cfg );
	return 0;
}

